package name.fowler.refactoring.simplestore.services;

import javax.faces.bean.ApplicationScoped;
import javax.inject.Inject;

/**
 * Date: 04.12.13
 * Time: 9:14
 */

@ApplicationScoped
public class ReportBuilderFactory {
    @Inject
    private InListFormatter inListFormatter;
    @Inject
    private InRowFormatter inRowFormatter;
    @Inject
    private ReportAllDebitors reportAllDebitors;
    @Inject
    private ReportRentalMovies reportRentalMovies;

    public ReportBuilder create(String repType, String formatType) {
        Report r = null;
        switch (repType){
            case "allDebitors" : r = reportAllDebitors; break;
            case "rentalMovie" : r = reportRentalMovies; break;
        }
        Formatter f = null;
        switch (formatType){
            case "inList" : f = inListFormatter; break;
            case "inRow" : f = inRowFormatter; break;
        }
        return new ReportBuilder(f, r);
    }
}
